package org.starapp.rbac.rest;


import java.io.InputStream;

import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;


public class RestGet {
public static void main(String args[]){
	//------------------get---------------------------//
	//创建一个http客户端  
	HttpClient client=new DefaultHttpClient();  
	//创建一个GET请求  
	HttpGet httpGet=new HttpGet("http://localhost:8888/starapp-demo/api/v1/users");  
	try {
		//向服务器发送请求并获取服务器返回的结果  
		HttpResponse response = client.execute(httpGet);
		//返回的结果可能放到InputStream，http Header中等。  
		InputStream inputStream = response.getEntity().getContent();
		//System.out.println(FileUtils.getJsonFromInputStream(inputStream));
		Header[] headers = response.getAllHeaders();
		System.out.println(EntityUtils.toString(response.getEntity()));
		//System.out.println(FileUtils.getJsonFromInputStream(inputStream));
		inputStream.close();
		client.getConnectionManager().shutdown();
	} catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
	}  
}
}
